package com.xinz.server;

import java.io.IOException;

import com.xinz.protocal.config.ConfigFactory;
import com.xinz.server.socket.SpotNettySocketServer;

public abstract class SpotNettyServer {

	String host;
	
	int port;
	
	ConfigFactory factory;
	
	public SpotNettyServer(String host, int port, ConfigFactory factory) {
		this.host = host;
		this.port = port;
		this.factory = factory;
	}
	
	public static SpotNettyServer createSocketServer(String host, int port, ConfigFactory factory) {
		return new SpotNettySocketServer(host, port, factory);
	}
	
	public void run() {
		try {
			startup(port);
		}
		catch(IOException e) {
			e.printStackTrace();
		}
	}
	
	protected abstract void startup(int port) throws IOException;
	
	public abstract void addSessionListener(SessionListener listener);
	
	public abstract void removeSessionListener(SessionListener listener);
}
